<?php



namespace Admin\Model;



use Think\Model;



/**

* 

*/

class AuthModel extends Model

{

	/**

	 * [courselist description]

	 * @param  string $passed 是否审核通过 0待审核，1通过，2未通过

	 * @return [type]         [description]

	 * @author qlj

	 */

	public function authList($passed = ''){

		$where['a.passed'] = $passed;

		$where['a.status'] = 1;

		//分页

		 $count = $this -> field('a.*,u.nickname') -> alias('a') -> join('tutor_user_member as u on a.uid=u.id') -> where($where) -> order('a.create_time desc') -> limit($page->firstRow, $page->listRows) -> count();
		 
		$page = new \Think\Page($count, 10);

		$page -> setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');

		$pages = $page -> show();



		

		$data = $this -> field('a.*,u.nickname') -> alias('a') -> join('tutor_user_member as u on a.uid=u.id') -> where($where) -> order('a.create_time desc') -> limit($page->firstRow, $page->listRows) -> select();
		// echo M() ->_Sql();die;
		return array($data,$pages);



	}



	/**

	 * 修改Auth表

	 * @param  [int] $uid  [用户id]

	 * @param  [int] $val  [值]

	 * @param  [str] $flag [待修改的字段名称]

	 * @return [int]       [受影响的行数]

	 * @author qlj

	 */

	public function edit($uid,$val,$flag){

		return $this -> where(array('uid' => $uid)) -> save(array($flag => $val));

	}

}